/**
 * 
 */
package org.hotpotmaterial.codegenn2.controller;

import org.hotpotmaterial.codegenn2.common.ResultCodeConstants;
import org.hotpotmaterial.codegenn2.dto.ResultBaseDTO;
import org.hotpotmaterial.codegenn2.exception.CodeCommonException;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

/**
 * @author Wenxing
 *
 */
@ControllerAdvice
public class CodeExceptionHandler {
	
	@ExceptionHandler(CodeCommonException.class)
    public ResponseEntity<ResultBaseDTO> codeCommonException(CodeCommonException e) {
		ResultBaseDTO result = new ResultBaseDTO();
		result.setMsg(e.getMessage());
		result.setCode(ResultCodeConstants.CODE_DATA_ERROR);
		return new ResponseEntity<>(result, HttpStatus.OK);
    }

}
